// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_INV_DISPATCH_ITEM
// * CreateDate    : 2011/8/16 10:16:40
// * Creater       : CodeSmith
// * LastChangeDate: 2011/8/16 10:16:40
// * LastChanger   : 2011/8/16 10:16:40
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Inv
{
    /// <summary>
    /// InvDispatchItem
    /// </summary>
    public partial class InvDispatchItemBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objInvDispatchItemEntity">Entity</param>
        /// <returns>Entity</returns>
        public static InvDispatchItemEntity GetInvDispatchItem(InvDispatchItemEntity objInvDispatchItemEntity)
        {
            return DataAccess.SelectSingle<InvDispatchItemEntity>(objInvDispatchItemEntity);
        }

        public static DataSet GetDataSetByDispatchOrderId(string OrderId)
        {
            if (OrderId == null)
            {
                return null;
            }
            string sql = @"select A.*,B.ORDER_CODE,C.PRODUCT_CODE,C.PRODUCT_NAME,C.DESCRIPTION,E.LOCATION_CODE,F.WAREHOUSE_CODE,F.WAREHOUSE_NAME,
                            C.UNIT,C.MINOR_UNIT,C.FORMUAL 
                            from INV_DISPATCH_ITEM A 
                            left join INV_DISPATCH_ORDER B on a.DISPATCH_ORDER_ID=b.DISPATCH_ORDER_ID
                            left join MST_PRODUCT C on a.PRODUCT_ID=c.PRODUCT_ID
							left join INV_STORAGE G on A.PRODUCT_ID=G.PRODUCT_ID AND A.LOCATION_ID=G.LOCATION_ID
                            left join INV_DISPATCH_LOCATION D on a.DISPATCH_ITEM_ID=d.DISPATCH_ITEM_ID
                            left join MST_LOCATION E on G.LOCATION_ID=e.LOCATION_ID
                            left join MST_WAREHOUSE F on f.WAREHOUSE_CODE=e.WAREHOUSE_CODE
                            where a.DISPATCH_ORDER_ID='" + OrderId + "'";
            return DataAccess.SelectDataSet(sql);
        }
        #endregion


        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objInvDispatchItemEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertInvDispatchItem(InvDispatchItemEntity objInvDispatchItemEntity)
        {
            return DataAccess.Insert(objInvDispatchItemEntity);
        }

        public static bool InsertInvDispatchItem(List<InvDispatchItemEntity> objInvDispatchItemEntityList)
        {
            return DataAccess.Insert(objInvDispatchItemEntityList);
        }
        #endregion


        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objInvDispatchItemEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateInvDispatchItem(InvDispatchItemEntity objInvDispatchItemEntity)
        {
            return DataAccess.Update(objInvDispatchItemEntity);
        }

        public static bool UpdateInvDispatchItem(List<InvDispatchItemEntity> objInvDispatchItemEntityList)
        {
            return DataAccess.Update<InvDispatchItemEntity>(objInvDispatchItemEntityList);
        }
        #endregion


        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objInvDispatchItemEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteInvDispatchItem(InvDispatchItemEntity objInvDispatchItemEntity)
        {
            return DataAccess.Delete(objInvDispatchItemEntity);
        }

        public static bool DeleteInvDispatchItem(List<InvDispatchItemEntity> objInvDispatchItemEntityList)
        {
            return DataAccess.Delete<InvDispatchItemEntity>(objInvDispatchItemEntityList);
        }
        #endregion


        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetInvDispatchItemAll()
        {
            return DataAccess.SelectAllDataSet<InvDispatchItemEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<InvDispatchItemEntity> GetInvDispatchItemAllList()
        {
            return DataAccess.SelectAll<InvDispatchItemEntity>();
        }
        #endregion
    }


}

